package com.order.feign.fallback.factory;

import com.cloud.domain.TbUser;
import com.order.feign.UserClient;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @version 1.0
 * @author: yu.tan
 * @date: 2020/11/9 22:57
 * @Description: 容错类，实现FallbackFactory<为哪个接口实现容错>
 */
@Service
@Slf4j
public class UserFallBackFactory implements FallbackFactory<UserClient> {
    /**
     *
     * @param throwable frign调用过程中产生的异常
     * @return
     */
    @Override
    public UserClient create(Throwable throwable) {
        return new UserClient() {
            @Override
            public TbUser test() {
                log.error("{}",throwable);
                return null;
            }
        };
    }
}
